﻿@model Web.ViewModels.VacancyEditForm

<div class="lightbox" id="vacancyBox">
    	<a href="#" class="lightbox_close">Закрыть</a>	
		@using (Html.BeginForm("Edit", "Vacancy", FormMethod.Post, new { @class="ajaxForm", id="vacancyBoxForm"}))
  {
		<fieldset>
			@Html.HiddenFor(x => x.Id, new { id = "VacancyId" })
			@Html.LabelFor(x => x.Name, "Название")
			@Html.TextBoxFor(x => x.Name, new { id = "VacancyName", placeholder = "Дворник" })
            @Html.ValidationMessageFor(x => x.Name)

			<br />
			@Html.LabelFor(x => x.Description, "Описание")
			@Html.TextBoxFor(x => x.Description, new { id = "VacancyDescription", placeholder = "Собирать мусор" })
            @Html.ValidationMessageFor(x => x.Description)

			<br />
			@Html.LabelFor(x => x.NeededNumber, "Сколько человек")
			@Html.TextBoxFor(x => x.NeededNumber, new { id = "VacancyNeededNumber", placeholder = "8" })
            @Html.ValidationMessageFor(x => x.NeededNumber)

			<br />
			@Html.LabelFor(x => x.ApprovalRequired, "Требуется одобрение организатора")
			@Html.CheckBoxFor(x => x.ApprovalRequired, new { id = "VacancyApprovalRequired" })
		</fieldset>
		<div id="errorMessage" class="errorMessage"></div>
		@Html.SubmitButton(null, "Отправить")
  }
	</div>
    <script>
    	$(document).ready(function () {
	    $('#vacancyBoxForm')[0].success = yyy($('#vacancyBoxForm'));
	    function yyy(jf) {
	        return function success(data) {
	            if (data != null && data.ErrorMessage != null)
	                jf.children(".errorMessage").html(data.ErrorMessage);
	            else
	                window.location.reload();
	        };
	    }
	});
</script>